// pages/info/info.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    contentType: '200',
    page: 1,
    pageSize: 5,
    list: [{
        "bussinessType": 1,
        "content": "今天是星期五，天气非常晴朗。",
        "contentType": 0,
        "createUser": 1,
        "created": "04-12 17:25",
        "id": 1,
        "isRead": 0,
        "readTime": null,
        "relevantId": 1,
        "title": "Q0epFzjiyR8sbDFpFoOX",
        "updateUser": 2,
        "updated": "2023-04-15T06:11:23",
        "userId": 2
      },
      {
        "bussinessType": 1,
        "content": "上海的交通拥堵问题一直困扰着市民。",
        "contentType": 1,
        "createUser": 1,
        "created": "04-13 17:25",
        "id": 2,
        "isRead": 1,
        "readTime": "2023-03-09T00:42:33",
        "relevantId": 2,
        "title": "PtNJHDqv9h0YhMj8LjSS",
        "updateUser": 1,
        "updated": "2023-03-09T11:03:12",
        "userId": 2
      },
      {
        "bussinessType": 1,
        "content": "这道菜的味道很不错，吃起来很棒。",
        "contentType": 1,
        "createUser": 4,
        "created": "04-23 08:45",
        "id": 3,
        "isRead": 0,
        "readTime": null,
        "relevantId": 3,
        "title": "1oJqM323AUtlyAYXB6Lv",
        "updateUser": 3,
        "updated": "2023-04-25T03:13:22",
        "userId": 2
      },
      {
        "bussinessType": 0,
        "content": "这本书的作者是一位很有趣的人，他的故事非常有意思。",
        "contentType": 0,
        "createUser": 2,
        "created": "02-12 08:33",
        "id": 4,
        "isRead": 0,
        "readTime": null,
        "relevantId": 4,
        "title": "OnvAiJ4FwxHgd0QMArLs",
        "updateUser": 3,
        "updated": "2023-02-15 07:39:14",
        "userId": 3
      },
      {
        "bussinessType": 1,
        "content": "你喜欢什么样的音乐？我最近在听流行和摇滚",
        "contentType": 0,
        "createUser": 3,
        "created": "04-19 21:18",
        "id": 5,
        "isRead": 0,
        "readTime": null,
        "relevantId": 5,
        "title": "dSxm1Y6iVpMJp5k8RHdr",
        "updateUser": 3,
        "updated": "2023-04-20T13:35:26",
        "userId": 2
      }
    ],
    listTwo:[{id:1}],
    // listTwo:[],
    // taskId:''//任务通知id
  },
  nullTransition() {
    this.setData({
      nullNotice: false,
    })
  },
  transition() {
    this.setData({
      nullNotice: true,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    this.getNoticeList()
  },
  async getNoticeList() {
    const {
      contentType,
      page,
      pageSize
    } = this.data
    const res = await wx.http.get('/driver/messages/page', {
      contentType,
      page,
      pageSize
    })
    console.log('获取公告列表', res);
  },
  async readAll() { //全部已读
    const contentType = this.data.contentType
    const res = await wx.http.get('/driver/messages/page', {
      contentType
    })
    console.log(res);
    wx.$toast('全部已读接口无效!!!')
  },
  onChange(e) { //公告,通知切换
    // console.log('切换传200/201',e.detail.name);
    const contentType = e.detail.name
    this.setData({
      contentType
    })
  },
  viewTaskDetails(e) {
    console.log('查看任务详情',e.mark.id);
    // this.setData({taskId:e.mark.id})
    wx.navigateTo({
      url:'/subpkg_fask/pages/detail/detail?taskId='+e.mark.id
    })
  },
  async viewBulletinDetails(e) {
    console.log('查看公告详情',e.mark.id);
    const res = await wx.http.put('/driver/messages/'+e.mark.id)
    console.log(res);
    wx.$toast('改变是否已读状态,接口无效!!!')
    wx.navigateTo({
      url: '/subpkg_information/pages/order_list/index?id='+ e.mark.id,
    })
  }
})